<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="" id="formInfo">
            <!--<fieldset class="table-search-fieldset">-->
                <!--<legend>搜索信息</legend>-->
                <div style="margin: 10px 10px 10px 10px">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">搜索信息</label>
                            <div class="layui-input-inline">
                                <input type="text" name="searchInfo" placeholder="请输入姓名/手机号" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" id="area-picker">
                            <div class="layui-form-label">地区筛选</div>
                            <div class="layui-input-inline">
                                <select name="province" class="province-selector" lay-filter="province-1">
                                    <option value="">请选择省</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="city" class="city-selector" lay-filter="city-1">
                                    <option value="">请选择市</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="area" class="county-selector" lay-filter="county-1">
                                    <option value="">请选择区</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline" style="display: none">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </div>
            <!--</fieldset>-->
        </form>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="checkInfo">查看他的推荐</a>
        </script>
        <input type="hidden" id="memberCode">
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form', 'table', 'laydate','layarea'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layarea = layui.layarea,
            laydate = layui.laydate;
        /*城市级联*/
        layarea.render({
            elem: '#area-picker',
            change: function (res) {
                submitInfo();
            }
        });
        /*用户团队*/
        table.render({
            elem: '#currentTableId',
            url: '/admin/Member/memberTeam',
            method: 'post',
            where: {memberCode: "{$memberCode}",team_id:"{$team_id}"},
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data, //解析数据列表
                };
            },
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'head_portrait', title: '头像', sort: true, align: 'center',
                    templet: function (d) {
                        return '<div onclick="showImg(this)" ><img src="/upload/' + d.head_portrait + '" ' + 'alt="" width="50px" height="50px"></div>';
                    }},
                {field: 'name', title: '名称', sort: true, align: 'center'},
                {field: 'address', title: '地区', sort: true, align: 'center'},
                {field: 'code', title: 'ID', sort: true, align: 'center'},
                {field: 'phone', title: '手机号', sort: true, align: 'center'},
                {field: 'team_num', title: '玩家推荐数量', sort: true, align: 'center'},
                {field: 'team_earnings', title: '累计收益', sort: true, align: 'center'},
                {title: '操作', toolbar: '#currentTableBar'}
            ]],
            limits: [10, 15, 20, 25, 30, 50, 100],
            limit: 10,
            page: true,
            skin: 'line,row',
            done: function (res, curr, count) {

            }
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            submitInfo();
            return false;
        });
        function submitInfo() {
            var d = {};
            var t = $('#formInfo [name]').serializeArray();
            $.each(t, function () {
                d[this.name] = this.value;
            });
            var result = JSON.stringify(d);
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');
            return false;
        }
        /*查看他的推荐*/
        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'checkInfo') {
                layer.open({
                    type: 2,
                    title: '查看他的推荐',
                    shadeClose: true,
                    shade: 0.5,
                    area: ['100%', '100%'],
                    content: '/admin/Member/memberInfo?view=memberTeam&memberCode=' + data.code
                });
            }
        });

    });
    /*查看大图*/
    function showImg(t) {
        var t = $(t).find("img");
        //页面层
        layer.open({
            type: 1,
            title: '区域图片',
            skin: 'layui-layer-rim', //加上边框
            area: ['50%' ,'80%'], //宽高 t.width() t.height()
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" width=\'500px\'  style=\'margin-top: 25px;margin-left: 25px\'/></div>'
        });
    }
</script>

</body>
</html>